-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BlockBiquad shelf & peaking, AudioFilter support #9804
base: main
Are you sure you want to change the base?
Conversation
This is just `Biquad | BlockBiquad` but it's useful shorthand.
& test by filtering some noise with a pair of BlockBiquads
The formulae are untested but taken directly from the Cookbook. The `sqrt(A)` term is given a quick approximation via the famous Quake reciprocal square root routine.
[two builds overflowed, looks like] |
@jepler The updates look great to me so far, and I'm happy with the updates to |
@relic-se can you comment on this specifically?
|
this otherwise gets ``` astroid.exceptions.InferenceError: Inference failed for all members of [<BinOp l.13 at 0x7fd379c99e80>]. ```
@jepler Since the Here's an example of this in action: https://gist.github.com/relic-se/77e48df1920b20d3e50762cbc06d1bb9#file-audioeffects_microphone-py-L111-L112. If The example referenced relies on this PR, #9776, for the |
Just like using an LFO, math, or other object with a block input with two synthesizer objects is undefined, so is using an LFO with a synthesizer and an audiofilter...:
so sadly I have to say that the code linked above is relying on undefined behavior. I wish I had looked more closely at the use of block inputs in audiofilters because I would have asked that it be reworked to not rely on a side effect of a synthio.Synthesizer in this way. |
@@ -250,6 +241,8 @@ audioio_get_buffer_result_t audiofilters_filter_get_buffer(audiofilters_filter_o | |||
channel = 0; | |||
} | |||
|
|||
shared_bindings_synthio_lfo_tick(self->sample_rate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the merge of #9776 , shared_bindings_synthio_lfo_tick
and all synthio_block_slot_get
calls will need to be moved into the buffer loop at L258, a second num_samples
argument will need to be provided, and the buffer loop will need to be limited to SYNTHIO_MAX_DUR
samples per iteration. See Distortion.c for a good example of this which also ticks the blocks when no sample is provided.
while (length != 0) { |
@relic-se @gamblor21 @todbot for interest.
A potential limitation is:
(besides which, LFOs can now be used with AudioFilters, BlockBiquads, and other types of objects; LFOs, Math blocks and BlockBiquads should in the medium term be moved out of synthio into their own modules and the documentation updated to reflect what they can be used with)
AudioFilter is more likely to be used with AudioMixer. But you can't have one LFO drive the filters of two different AudioFilter objects.
I honestly don't know what the fix for this is. The
lfo_tick
routine needs to run once every SYNTHIO_MAX_DUR samples, but other parts of the audio pipeline produce or consume in different chunks. Using AudioMixer to gather up multiple chunks of synthio data is a common trick, but you still want the LFOs to tick every 256 samples even if AudioMixer is gathering 1024 samples at a time (ssay) In fact, this is making me doubt that a BlockBiquad with varying inputs is even working right in Filter with a single Filter and no mixer since it is using buffer_size of 512 bytes which might or might not be 256 samples.This needs more thought, so I'm entering this as a draft.